<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title></title>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
    </style>
  </head>
  <body>
    <input type="button" id="btn" value="click Me" />

    <script type="text/javascript">
      var btn = document.querySelector("#btn");

      btn.onclick = function () {
        this.style.background = [
          "yellow",
          "red",
          "green",
          "purple",
          "pink",
          "gray",
          "blue",
          "orange",
          "black",
          "cyan"
        ][Math.floor(Math.random() * 10)];
      };

      setInterval(function () {
        console.log(btn.style.background);
      }, 1000);
    </script>
  </body>
</html>
